<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<title>Genivia - address.cpp Source File</title>
<link href="genivia_tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="genivia_content.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="top">
 <div id="titlearea">
  <table height="72px" width="100%" cellspacing="0" cellpadding="0">
   <tbody>
    <tr>
     <td width="10%">&nbsp;</td>
     <td width="175px"><a href="https://www.genivia.com"><img alt="Genivia" src="GeniviaLogo2_trans_noslogan.png"/></a></td>
     <td class="tab_home"><a href="https://www.genivia.com">Home</a></td>
     <td class="tab_home"><a href="https://www.genivia.com/docs.html">Documentation</a></td>
     <td>
      <div style="float: right; font-size: 18px; font-weight: bold;">address.cpp Source File</div>
      <br>
      <div style="float: right; font-size: 10px;">updated Tue Sep 1 2020 by Robert van Engelen</div>
     </td>
     <td width="10%">&nbsp;</td>
    </tr>
   </tbody>
  </table>
 </div>
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('address_8cpp_source.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">address.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="address_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="comment">/*</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment">--------------------------------------------------------------------------------</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="comment">gSOAP XML Web services tools</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="comment">Copyright (C) 2000-2015, Robert van Engelen, Genivia, Inc. All Rights Reserved.</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="comment">This software is released under one of the following two licenses:</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="comment">GPL.</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="comment">--------------------------------------------------------------------------------</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="comment">GPL license.</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment"></span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="comment">This program is free software; you can redistribute it and/or modify it under</span></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="comment">the terms of the GNU General Public License as published by the Free Software</span></div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="comment">version.</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="comment"></span></div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT ANY</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="comment">WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="comment">PARTICULAR PURPOSE. See the GNU General Public License for more details.</span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<span class="comment"></span></div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="comment">You should have received a copy of the GNU General Public License along with</span></div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span></div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="comment">Place, Suite 330, Boston, MA 02111-1307 USA</span></div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="comment"></span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="comment">Author contact information:</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="comment">engelen@genivia.com / engelen@acm.org</span></div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="comment">--------------------------------------------------------------------------------</span></div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="comment">A commercial use license is available from Genivia, Inc., contact@genivia.com</span></div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="comment">--------------------------------------------------------------------------------</span></div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;<span class="comment">*/</span></div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<span class="keywordtype">int</span> <a class="code" href="address_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>();</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<span class="preprocessor">#include &lt;fstream&gt;</span></div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="preprocessor">#include &quot;addressH.h&quot;</span>   <span class="comment">// generated, also includes stdsoap2.h</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="preprocessor">#include &quot;a.nsmap&quot;</span>      <span class="comment">// generated</span></div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="keywordtype">char</span> *<a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *prompt);</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div><div class="line"><a name="l00081"></a><span class="lineno"><a class="line" href="address_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">   81</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="address_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>()</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;{</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;  <span class="comment">// New soap struct engine context</span></div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  <span class="comment">// Use strict validation and indented canonicalized output</span></div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;  <span class="keyword">struct </span>soap *soap = soap_new1(SOAP_XML_STRICT | SOAP_XML_INDENT | SOAP_XML_NOTYPE);</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;  _a__address_book *ab = soap_new__a__address_book(soap, -1);</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  std::fstream fs;</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;  <span class="comment">// Read the address book from address.xml (defined by address.xsd)</span></div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  fs.open(<span class="stringliteral">&quot;address.xml&quot;</span>, std::ios::in);</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;  <span class="keywordflow">if</span> (fs)</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  {</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    soap-&gt;is = &amp;fs;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    <span class="keywordflow">if</span> (soap_read__a__address_book(soap, ab) != SOAP_OK)</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    { </div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;      std::cerr &lt;&lt; <span class="stringliteral">&quot;Error reading address.xml file&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;      soap_stream_fault(soap, std::cerr);</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;      exit(1);</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    }</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    fs.close();</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;  }</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;  <span class="comment">// Display the address book content</span></div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;  std::cout &lt;&lt; std::endl &lt;&lt; <span class="stringliteral">&quot;ADDRESS BOOK - An Example XML Data Binding Application&quot;</span> &lt;&lt; std::endl &lt;&lt; std::endl;</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;  <span class="keywordflow">for</span> (std::vector&lt;a__address*&gt;::const_iterator i = ab-&gt;address.begin(); i != ab-&gt;address.end(); ++i)</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;  {</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keywordflow">if</span> (*i)</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    {</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;Address entry &quot;</span> &lt;&lt; (*i)-&gt;ID &lt;&lt; std::endl;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;Name:    &quot;</span> &lt;&lt; (*i)-&gt;name &lt;&lt; std::endl;</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;Street:  &quot;</span> &lt;&lt; (*i)-&gt;street &lt;&lt; std::endl;</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;City:    &quot;</span> &lt;&lt; (*i)-&gt;city &lt;&lt; std::endl;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;Zip:     &quot;</span> &lt;&lt; (*i)-&gt;zip &lt;&lt; std::endl;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;      <span class="comment">// Advanced level: we use the soapcpp2-generated soap_a__ISO_country2s()</span></div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;      <span class="comment">// function to convert enum a__ISO_country values to strings. The strings</span></div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;      <span class="comment">// are allocated in the gSOAP engine and deleted with soap_end()</span></div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;Country: &quot;</span> &lt;&lt; soap_a__ISO_country2s(soap, (*i)-&gt;country) &lt;&lt;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;      std::endl;</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;      <span class="keywordflow">if</span> ((*i)-&gt;phone)</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        std::cout &lt;&lt; <span class="stringliteral">&quot;Phone:   &quot;</span> &lt;&lt; *(*i)-&gt;phone &lt;&lt; std::endl;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;      <span class="keywordflow">if</span> ((*i)-&gt;mobile)</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        std::cout &lt;&lt; <span class="stringliteral">&quot;Mobile:  &quot;</span> &lt;&lt; *(*i)-&gt;mobile &lt;&lt; std::endl;</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;      <span class="comment">// Advanced level: use the soap_dateTime2s() from the stdsoap2.cpp engine</span></div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;      <span class="keywordflow">if</span> ((*i)-&gt;dob)</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        std::cout &lt;&lt; <span class="stringliteral">&quot;DOB:     &quot;</span> &lt;&lt; soap_dateTime2s(soap, *(*i)-&gt;dob) &lt;&lt; std::endl;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;      std::cout &lt;&lt; <span class="stringliteral">&quot;---------&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    }</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  }</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;  <span class="comment">// Allocate a new address in the gSOAP engine&#39;s data space</span></div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  a__address *a = soap_new_a__address(soap, -1);</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;  <span class="comment">// Set object&#39;s default values (soap_default is generated)</span></div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;  a-&gt;soap_default(soap);</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;  a-&gt;ID = ab-&gt;address.size() + 1;</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;  std::cout &lt;&lt; <span class="stringliteral">&quot;Enter a new contact:&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;  a-&gt;name = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;Name&quot;</span>);</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;  a-&gt;street = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;Street&quot;</span>);</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  a-&gt;city = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;City&quot;</span>);</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  a-&gt;zip = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;Zip&quot;</span>);</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;  <span class="keywordtype">char</span> *s;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;  <span class="keywordflow">do</span> {</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    s = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;Country&quot;</span>);</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <span class="comment">// Advanced level: use the generated s2a__ISO_country() to convert string to</span></div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="comment">// enum constant</span></div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    soap-&gt;error = SOAP_OK;</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    <span class="keywordflow">if</span> (soap_s2a__ISO_country(soap, s, &amp;a-&gt;country) != SOAP_OK)</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;      std::cerr &lt;&lt; <span class="stringliteral">&quot;Not a valid country code&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;  }</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  <span class="keywordflow">while</span> (soap-&gt;error);</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  <span class="keywordflow">if</span> (*(s = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;Phone&quot;</span>)))</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;  {</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <span class="comment">// Allocate string in engine&#39;s data space:</span></div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    a-&gt;phone = soap_new_std__string(soap, -1);</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    *a-&gt;phone = s;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  } </div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;  <span class="keywordflow">if</span> (*(s = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;Mobile&quot;</span>)))</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;  {</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    <span class="comment">// Allocate string in engine&#39;s data space:</span></div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    a-&gt;mobile = soap_new_std__string(soap, -1);</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;    *a-&gt;mobile = s;</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;  } </div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;  <span class="comment">// change soap_s2dateTime to soap_xsd__dateTime when overriding the default xsd:dateTime to time_t mapping</span></div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;  <span class="keywordflow">if</span> (*(s = <a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="stringliteral">&quot;DOB&quot;</span>)))</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;    <span class="keywordflow">if</span> (soap_s2dateTime(soap, s, a-&gt;dob) != SOAP_OK)</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;      std::cerr &lt;&lt; <span class="stringliteral">&quot;Not a valid ISO 8601 date time (ignored)&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;  soap-&gt;error = SOAP_OK;</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  <span class="comment">// Add contact to address book</span></div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;  ab-&gt;address.push_back(a);</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;  std::cout &lt;&lt; std::endl &lt;&lt; <span class="stringliteral">&quot;Contact information added.&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;  <span class="comment">// Save updated address book to address.xml</span></div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;  fs.open(<span class="stringliteral">&quot;address.xml&quot;</span>, std::ios::out);</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;  <span class="keywordflow">if</span> (!fs)</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;  {</div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    std::cerr &lt;&lt; <span class="stringliteral">&quot;Cannot create address.xml file&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    exit(1);</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;  }</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;  soap-&gt;os = &amp;fs;</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;  <span class="keywordflow">if</span> (soap_write__a__address_book(soap, ab) != SOAP_OK)</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;  {</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;    std::cerr &lt;&lt; <span class="stringliteral">&quot;Error writing address.xml file&quot;</span> &lt;&lt; std::endl;</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    soap_stream_fault(soap, std::cerr);</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    exit(1);</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;  }</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  fs.close();</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;  <span class="comment">// Delete instances</span></div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;  soap_destroy(soap);</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;  <span class="comment">// Delete data</span></div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;  soap_end(soap);</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;  <span class="comment">// Free soap struct engine context</span></div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;  soap_free(soap);</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;}</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;</div><div class="line"><a name="l00203"></a><span class="lineno"><a class="line" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">  203</a></span>&#160;<span class="keywordtype">char</span> *<a class="code" href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *prompt)</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;{</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;  <span class="keyword">static</span> <span class="keywordtype">char</span> buf[80];</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;  <span class="keywordtype">char</span> *s;</div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;  printf(<span class="stringliteral">&quot;%-9s&gt; &quot;</span>, prompt);</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;  fgets(buf, 80, stdin);</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;  <span class="comment">// Strip trailing space</span></div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;  <span class="keywordflow">for</span> (s = buf + strlen(buf) - 1; s &gt; buf; s--)</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;  {</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    <span class="keywordflow">if</span> (*s &gt; <span class="charliteral">&#39; &#39;</span>)</div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;      <span class="keywordflow">break</span>;</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;  }</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;  s[1] = <span class="charliteral">&#39;\0&#39;</span>;</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;  <span class="comment">// Strip leading space</span></div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;  <span class="keywordflow">for</span> (s = buf; *s; s++)</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;  {</div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;    <span class="keywordflow">if</span> (*s &gt; <span class="charliteral">&#39; &#39;</span>)</div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;      <span class="keywordflow">break</span>;</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;  }</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;  <span class="keywordflow">return</span> s;</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;}</div><div class="ttc" id="address_8cpp_html_ab9e04a47deea0760ed07e2e62023e890"><div class="ttname"><a href="address_8cpp.html#ab9e04a47deea0760ed07e2e62023e890">user_input</a></div><div class="ttdeci">char * user_input(const char *prompt)</div><div class="ttdoc">A quick-and-dirty user input function: reads string from stdin (up to 80 chars), trims leading and tr...</div><div class="ttdef"><b>Definition:</b> <a href="address_8cpp_source.html#l00203">address.cpp:203</a></div></div>
<div class="ttc" id="address_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="address_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">Address book application: reads address.xml, displays its content, prompts the user for new contact...</div><div class="ttdef"><b>Definition:</b> <a href="address_8cpp_source.html#l00081">address.cpp:81</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<hr class="footer">
<address class="footer">
Copyright (C) 2020, Robert van Engelen, Genivia Inc., All Rights Reserved.
</address>
<address class="footer"><small>
Converted on Tue Sep 1 2020 10:43:48 by <a target="_blank" href="http://www.doxygen.org/index.html">Doxygen</a> 1.8.11</small></address>
<br>
<div style="height: 246px; background: #DBDBDB;">
</body>
</html>
